//日期转换
Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
//展示首页.js
var sebantu;

var dq = null;
var selFarmid = null;
var showCityForcastFlag = true;
var showAlarmFlag = true;
var showSbtuFlag = false;
var showWindCanvasFlag = false;
var flag = false;
var WarningWord = null;
var currentData_time_cache = null;


$(function(){

    /** 左侧边栏光伏电站信息*/
    //光伏电站（日）
    getSfMetSkDay()
    //光伏电站（月）
    getSfMetSkMonth()
    //光伏电站（年）
    getSfMetSkYear()

    //风电站(日)
    getWfMetSkDay()
    //风电站(月)
    getWfMetSkMonth()
    //风电站(年)
    getWfMetSkYear()

    //获取预警数据
    getAlarmData()

    //顶部按钮切换
    $(".index-header-weather a").click(function(){
        //$(".index-header-weather a").removeClass("active");
        if($(this).hasClass("active")){
            $(this).removeClass("active");
        }else {
            $(this).addClass("active");
        }

    });

    getAllStation();
    $('#dataNo').on('click', function () {
        $.ajax({
            url : "../home/getAllStation",
            type : "get",
            contentType : "application/json",
            dataType : "json",
            data :{}/*JSON.stringify(data)*/,//转换成字符串。后台使用了RequestBody注解
            success : function(data) {
                alert("今日未预报电站："+JSON.parse(data.disStations));
            }
        });
    });

    InitMap();
    addStation();

    //加载天气预报和预警
    addWeather();
    //刷新周期从5分钟改成了15分钟，by 孙延维 20221003
    setInterval('addWeather()',1000*60*5*3);//定时刷新

    //初始化加载全部站点的数据
    $(".farmType").hover(function (e) {
        var farmType = e.target.id;
        layer.tips('点击显示电场数据', '#' + farmType, {
            tips: 3
        });
    }, function () {
        //$("#mark-info").hide();
    })

    $(".farmTypeShui").hover(function (e) {
        var farmType = e.target.id;
        layer.tips('点击显示水电数据', '#' + farmType, {
            // 1上；2右；3下；4左
            tips: 3
        });
    }, function () {
    })

    $(".farmTypeHuo").hover(function (e) {
        var farmType = e.target.id;
        layer.tips('点击显示火电数据', '#' + farmType, {
            tips: 3
        });
    }, function () {
    })

    $(".farmTypeFenbushi").hover(function (e) {
        var farmType = e.target.id;
        layer.tips('点击显示分布式数据', '#' + farmType, {
            tips: 3
        });
    }, function () {
    })
    //首页左侧数据
    leftInfo();
    //初始化调用全部风电场的数据
    loadFarmData("ALL");
    getCdqSum();
});

//初始化发布预警
function getAlarmData() {
    $.ajax({
        url : "../metAlarm/getAlarmCount",
        type : "get",
        contentType : "application/json",
        dataType : "json",
        success : function(data) {
            $('#alarm_day').html(data[0]);
            $('#alarm_month').html(data[1]);
            $('#alarm_year').html(data[2]);
        }
    });
}


//初始化光伏电站（日）
function getSfMetSkDay(farmid) {
    var p={
        farmid:farmid,
    };
    $.ajax({
        url : "../sfMetSk/getSfInfo",
        type : "get",
        contentType : "application/json",
        dataType : "json",
        data : p,
        success : function(data) {
            if(data.sfMetSkVOListDay[0].avgWindSpeed!= null) {
                $('#avgWindSpeed').html(data.sfMetSkVOListDay[0].avgWindSpeed.toFixed(1) + 'm/s');
            }
            if(data.sfMetSkVOListDay[0].avgTemp != null) {
                $('#avgTemp').html(data.sfMetSkVOListDay[0].avgTemp.toFixed(1) + '℃');
            }
            if(data.sfMetSkVOListDay[0].humidity != null) {
                $('#avgHumid').html(data.sfMetSkVOListDay[0].humidity.toFixed(1) + '%');
            }
            if(data.sfMetSkVOListDay[0].sunHour != null) {
                $('#sunHour').html(data.sfMetSkVOListDay[0].sunHour.toFixed(1) + 'h');
            }
            if(data.sfMetSkVOListDay[0].directRadiation != null) {
                $('#horizontalTotalRaditation').html(data.sfMetSkVOListDay[0].directRadiation.toFixed(1) + 'kwh/㎡');
            }
            if(data.sfMetSkVOListDay[0].scatteredRadiation != null) {
                $('#tileTotalRadiation').html(data.sfMetSkVOListDay[0].scatteredRadiation.toFixed(1) + 'kwh/㎡');
            }
        }
    });
}

//初始化光伏电站（月）
function getSfMetSkMonth(farmid) {
    var p={
        farmid:farmid,
    };
    $.ajax({
        url : "../sfMetSk/getSfInfo",
        type : "get",
        contentType : "application/json",
        dataType : "json",
        data : p,
        success : function(data) {
            if(data.sfMetSkVOListMonth[0].avgWindSpeed != null) {
                $('#avgWindSpeed2').html(data.sfMetSkVOListMonth[0].avgWindSpeed.toFixed(1) + 'm/s');
            }
            if(data.sfMetSkVOListMonth[0].avgTemp != null) {
                $('#avgTemp2').html(data.sfMetSkVOListMonth[0].avgTemp.toFixed(1) + '℃');
            }
            if(data.sfMetSkVOListMonth[0].humidity != null) {
                $('#avgHumid2').html(data.sfMetSkVOListMonth[0].humidity.toFixed(1) + '%');
            }
            if(data.sfMetSkVOListMonth[0].sunHour != null) {
                $('#sunHour2').html(data.sfMetSkVOListMonth[0].sunHour.toFixed(1) + 'h');
            }
            if(data.sfMetSkVOListMonth[0].directRadiation != null) {
                $('#horizontalTotalRaditation2').html(data.sfMetSkVOListMonth[0].directRadiation.toFixed(1) + 'kwh/㎡');
            }
            if(data.sfMetSkVOListMonth[0].scatteredRadiation != null) {
                $('#tileTotalRadiation2').html(data.sfMetSkVOListMonth[0].scatteredRadiation.toFixed(1) + 'kwh/㎡');
            }
        }
    });
}

//初始化光伏电站（年）
function getSfMetSkYear(farmid) {
    var p={
        farmid:farmid,
    };
    $.ajax({
        url : "../sfMetSk/getSfInfo",
        type : "get",
        contentType : "application/json",
        dataType : "json",
        data : p,
        success : function(data) {
            if(data.sfMetSkVOListYear[0].avgWindSpeed != null) {
                $('#avgWindSpeed3').html(data.sfMetSkVOListYear[0].avgWindSpeed.toFixed(1) + 'm/s');
            }
            if(data.sfMetSkVOListYear[0].avgTemp != null) {
                $('#avgTemp3').html(data.sfMetSkVOListYear[0].avgTemp.toFixed(1) + '℃');
            }
            if(data.sfMetSkVOListYear[0].humidity != null) {
                $('#avgHumid3').html(data.sfMetSkVOListYear[0].humidity.toFixed(1) + '%');
            }
            if(data.sfMetSkVOListYear[0].sunHour != null) {
                $('#sunHour3').html(data.sfMetSkVOListYear[0].sunHour.toFixed(1) + 'h');
            }
            if(data.sfMetSkVOListYear[0].directRadiation != null) {
                $('#horizontalTotalRaditation3').html(data.sfMetSkVOListYear[0].directRadiation.toFixed(1) + 'kwh/㎡');
            }
            if(data.sfMetSkVOListYear[0].scatteredRadiation != null) {
                $('#tileTotalRadiation3').html(data.sfMetSkVOListYear[0].scatteredRadiation.toFixed(1) + 'kwh/㎡');
            }
        }
    });
}

//初始化风电站(日)
function getWfMetSkDay(farmid) {
    var p={
        farmid:farmid,
    };
    $.ajax({
        url : "../wfMetSk/getWfInfo",
        type : "get",
        contentType : "application/json",
        dataType : "json",
        data : p,
        success : function(data) {
            if(data.wfMetSkVOSDay[0].wind10mSpeed != null) {
                $('#avg10mWindSpeed').html(data.wfMetSkVOSDay[0].wind10mSpeed.toFixed(1) + 'm/s');
            }
            if(data.wfMetSkVOSDay[0].wind50mSpeed != null) {
                $('#avg50mWindSpeed').html(data.wfMetSkVOSDay[0].wind50mSpeed.toFixed(1) + 'm/s');
            }
            if(data.wfMetSkVOSDay[0].wind70mSpeed != null) {
                $('#avg70mWindSpeed').html(data.wfMetSkVOSDay[0].wind70mSpeed.toFixed(1) + 'm/s');
            }
            if(data.wfMetSkVOSDay[0].windHubSpeed != null) {
                $('#avgHubWindSpeed').html(data.wfMetSkVOSDay[0].windHubSpeed.toFixed(1) + 'm/s');
            }
            if(data.wfMetSkVOSDay[0].avgTemp != null) {
                $('#avgTempFdz').html(data.wfMetSkVOSDay[0].avgTemp.toFixed(1) + '℃');
            }
            if(data.wfMetSkVOSDay[0].pressure != null) {
                $('#pressureFdz').html(data.wfMetSkVOSDay[0].pressure.toFixed(1) + 'Pa');
            }
        }
    });
}
//初始化风电站(月)
function getWfMetSkMonth(farmid) {
    var p={
        farmid:farmid,
    };
    $.ajax({
        url : "../wfMetSk/getWfInfo",
        type : "get",
        contentType : "application/json",
        dataType : "json",
        data : p,
        success : function(data) {
            if(data.wfMetSkVOSMonth[0].wind10mSpeed != null) {
                $('#avg10mWindSpeed2').html(data.wfMetSkVOSMonth[0].wind10mSpeed.toFixed(2) + 'm/s');
            }
            if(data.wfMetSkVOSMonth[0].wind50mSpeed != null) {
                $('#avg50mWindSpeed2').html(data.wfMetSkVOSMonth[0].wind50mSpeed.toFixed(2) + 'm/s');
            }
            if(data.wfMetSkVOSMonth[0].wind70mSpeed != null) {
                $('#avg70mWindSpeed2').html(data.wfMetSkVOSMonth[0].wind70mSpeed.toFixed(2) + 'm/s');
            }
            if(data.wfMetSkVOSMonth[0].windHubSpeed != null) {
                $('#avgHubWindSpeed2').html(data.wfMetSkVOSMonth[0].windHubSpeed.toFixed(2) + 'm/s');
            }
            if(data.wfMetSkVOSMonth[0].avgTemp != null) {
                $('#avgTempFdz2').html(data.wfMetSkVOSMonth[0].avgTemp.toFixed(1) + '℃');
            }
            if(data.wfMetSkVOSMonth[0].pressure != null) {
                $('#pressureFdz2').html(data.wfMetSkVOSMonth[0].pressure.toFixed(1) + 'Pa');
            }
        }
    });
}
//初始化风电站(年)
function getWfMetSkYear(farmid) {
    var p={
        farmid:farmid,
    };
    $.ajax({
        url : "../wfMetSk/getWfInfo",
        type : "get",
        contentType : "application/json",
        dataType : "json",
        data : p,
        success : function(data) {
            if(data.wfMetSkVOSYear[0].wind10mSpeed != null) {
                $('#avg10mWindSpeed3').html(data.wfMetSkVOSYear[0].wind10mSpeed.toFixed(2) + 'm/s');
            }
            if(data.wfMetSkVOSYear[0].wind50mSpeed != null) {
                $('#avg50mWindSpeed3').html(data.wfMetSkVOSYear[0].wind50mSpeed.toFixed(2) + 'm/s');
            }
            if(data.wfMetSkVOSYear[0].wind70mSpeed != null) {
                $('#avg70mWindSpeed3').html(data.wfMetSkVOSYear[0].wind70mSpeed.toFixed(2) + 'm/s');
            }
            if(data.wfMetSkVOSYear[0].windHubSpeed != null) {
                $('#avgHubWindSpeed3').html(data.wfMetSkVOSYear[0].windHubSpeed.toFixed(2) + 'm/s');
            }
            if(data.wfMetSkVOSYear[0].avgTemp != null) {
                $('#avgTempFdz3').html(data.wfMetSkVOSYear[0].avgTemp.toFixed(1) + '℃');
            }
            if(data.wfMetSkVOSYear[0].pressure != null) {
                $('#pressureFdz3').html(data.wfMetSkVOSYear[0].pressure.toFixed(1) + 'Pa');
            }
        }
    });
}
//获取所有北部和中东部光伏总和、风电总和
function getCdqSum(){
    var p = {
        "type":'all'
    };
    $.ajax({
        url : "../home/cdqPower",
        type : "get",
        contentType : "application/json",
        dataType : "json",
        data : p,
        success : function(data) {
            if(data.northWfPowerTotal >= 0) {
                $('#northCdqWfValue').html(data.northWfPowerTotal.toFixed(2) + 'MW');
            }
            if(data.northSfPowerTotal >= 0) {
                $('#northCdqSfValue').html(data.northSfPowerTotal.toFixed(2) + 'MW');
            }
            if(data.centerWfPowerTotal >= 0) {
                $('#centerCdqWfValue').html(data.centerWfPowerTotal.toFixed(2) + 'MW');
            }
            if(data.centerSfPowerTotal >= 0) {
                $('#centerCdqSfValue').html(data.centerSfPowerTotal.toFixed(2) + 'MW');
            }
        }
    });

}

var cars = $("#tgBigox").width();
var i =-800;
function start(){
    var x=document.getElementById("warningword");
    x.innerHTML=WarningWord;
    i--;
    if(i<=-cars){
        i=cars;
        document.getElementById('tgGoox').style.right =-cars+'px';
    }else{
        document.getElementById('tgGoox').style.left =i+'px';
    }
    setTimeout(start,10);
}
//onload=function(){setTimeout(start,1000)};

//获取所有电站和
function getAllStation(){
    $.ajax({
        url : "../home/getAllStation",
        type : "get",
        contentType : "application/json",
        dataType : "json",
        data :{}/*JSON.stringify(data)*/,//转换成字符串。后台使用了RequestBody注解
        success : function(data) {
            $('#dataSum').html(data.allStations);
            $('#dataNo').html(data.disStationsSize);
        }
    });

}
/**
 *通过修改地图对的中心点位置和resolutions中的值将地图换成了湖北能源地图
 * 参数是从static的hb_xny目录下的info.json文件中获得
 */
var map = null;
function InitMap(){
    //坐标参考系统 crs 的设置：
    //1.记住spatialReference后的数字SRNumber。
    //2.然后到 "http://spatialreference.org/ref/epsg/[SRNumber]/proj4/" 复制内容得到坐标参数
    var origin = [-400, 400]; //裁图原点

    var crs = new L.Proj.CRS("EPSG:4326", "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ",
        {
            origin: origin,
            resolutions: [
                0.00951784402332112,
                0.0071383830174908411,
                0.00475892201166056,
                0.00237946100583028,
                0.00118973050291514,
                0.00059486525145757
            ]
        });


    //地图中心点设置
    var centerPoint = new L.LatLng(31.15, 112.24);

    var mapOptions = {
        center: centerPoint,
        zoom: 0.1,   //初始化地图的缩放级数
        crs: crs,
        continuousWorld: true,
        zoomControl: false,
        zoomControl:false,//屏蔽缩放工具
        attributionControl:false,//屏蔽右下角属性提示控件
        fileType:"PNG"
    };
    map = L.map('index-map', mapOptions);

    //加载HXLC地图切片
    var tileLayer = L.hxlc.tiledMapLayer({
        //url: 'http://59.172.25.122:8207/hb_xny',  //切片根目录
        url: '../hb_xny',  //切片根目录
        maxZoom: 5,
        minZoom: 0,
        continuousWorld: true,
        tileSize:256   //切片大小
    });
    map.addLayer(tileLayer);


    map.on('zoomstart', function () {
        if(!map.hasLayer(sebantu)){

        }else {
            map.removeLayer(sebantu);
        }
    });
    map.on('zoomend', function () {
        if(flag==true){
            map.addLayer(sebantu);
        }
    });
}

var markergroup_FD = [];
var markergroup_GF = [];
var markergroup_weahther = [];
var markergroup_yj = [];
var windCanvsLayer = null;



//加载站点
function addStation(){
    var iconUrl_gf = '../img/header-icon2.png';
    var iconUrl_fd = '../img/header-icon1.png';
    var LeafIcon = L.Icon.extend({
        options: {
            iconSize: [20, 30],//width height
            iconAnchor: [0, 0], //左  上
        }
    });

    $.ajax({
        url: "../windManage/selectAll",
        data: {},
        type: "post",
        success: function (data) {
            if(data){

                for(var i=0;i<JSON.parse(data).length;i++){
                    var farmaddress = JSON.parse(data)[i].farmaddress;
                    var FARMTYPE = JSON.parse(data)[i].farmtype;
                    if(FARMTYPE=='0'){//风电
                        var LAT_FD = JSON.parse(data)[i].lat;
                        var LON_FD = JSON.parse(data)[i].lon;
                        var FARMID = JSON.parse(data)[i].farmid;
                        markergroup_FD._data = JSON.parse(data)[i];
                        var Icons_fd = new LeafIcon({iconUrl: iconUrl_fd});
                        var myIcon = L.divIcon({
                            className: 'my-div-icon',
                            html: '<div style="height: auto;width: 150px;position:absolute;outline: none;">'
                                +'<div style="float: left;margin-right: 5px">' +
                                '<img  id="'+FARMID+'" style="position:absolute;width:20px;height:30px;outline: none;-moz-user-select:none;cursor:pointer;z-index:10000;" src="../img/header-icon1.png" >' +
                                '</div>'
                                +'</div>'

                        });
                        var marker_fd = L.marker([LAT_FD, LON_FD], {icon: myIcon});
                        markergroup_FD.push(marker_fd);
                        marker_fd.addTo(map);
                        marker_fd._data = JSON.parse(data)[i];

                        marker_fd.on('click', mouseClickMarker);
                        marker_fd.on('mouseover', mouseoverMarker);
                        //marker.on('click', markerClick);
                    }else if(FARMTYPE=='1'){//光伏
                        var LAT_GF = JSON.parse(data)[i].lat;
                        var LON_GF = JSON.parse(data)[i].lon;
                        var FARMID = JSON.parse(data)[i].farmid;
                        markergroup_GF._data = JSON.parse(data)[i];
                        var myIcon = L.divIcon({
                            className: 'my-div-icon',
                            html: '<div style="height: auto;width: 150px;position:absolute;outline: none;">'
                                +'<div style="float: left;margin-right: 5px">' +
                                '<img  id="'+FARMID+'" style="position:absolute;width:20px;height:30px;outline: none;-moz-user-select:none;cursor:pointer;z-index:10000;" src="../img/header-icon2.png" >' +
                                '</div>'
                                +'</div>'

                        });
                        var Icons_gf = new LeafIcon({iconUrl: iconUrl_gf});
                        var marker_gf = L.marker([LAT_GF, LON_GF], {icon: myIcon});
                        markergroup_GF.push(marker_gf);
                        marker_gf.addTo(map);
                        marker_gf._data = JSON.parse(data)[i];
                        marker_gf.on('click', mouseClickMarker);
                        marker_gf.on('mouseover', mouseoverMarker);
                    }


                    /*var Icons_gf = new LeafIcon({iconUrl: iconUrl_gf});
                    var Icons_fd = new LeafIcon({iconUrl: iconUrl_fd});*/
                    /*marker_fd.addTo(map);
                    marker_gf.addTo(map);*/

                }

            }
        }
    })
}

//点击站点图标事件
function mouseClickMarker(e){
    var farmName =e.target._data.farmname;
    var farmID =e.target._data.farmid;
    var farmtype =e.target._data.farmtype;
    $('#dataSpace').html(farmName);

    //首页数据加载调用 参数为farmID
    loadOneStationData(farmID,farmtype);

    //点击站点图标后左侧光伏电站
    getSfMetSkDay(farmID)
    getSfMetSkMonth(farmID)
    getSfMetSkYear(farmID)

    //点击站点图标后右侧风电站
    getWfMetSkDay(farmID)
    getWfMetSkMonth(farmID)
    getWfMetSkYear(farmID)
}
function mouseoverMarker(e){
    var farmID =e.target._data.farmid;
    $.ajax({
        url: "../shortPeriodManage/getFarmNowData",
        data: {farmid:farmID},
        type: "post",
        success: function (data) {
            if(!data.power.FARMNAME){
                layer.msg('暂无数据')
                return;
            }
            var farmName = data.power.FARMNAME;
            if(data.power.ACTIVEPOWER == null){
                var activepower= '功率:　  MW';
            }else {
                var activepower= '功率: '+data.power.ACTIVEPOWER.toFixed(2)+' MW';
            }

            var totalradiation = null;
            if(data.power.farmtype==1){
                $.each(data.radiation, function (index, item) {
                    if(item.totalradiation!=null){
                        totalradiation = '辐射: '+item.totalradiation.toFixed(2)+' W/㎡';
                    }
                });
                if(totalradiation == null){
                    totalradiation = '辐射:　  W/㎡';
                }
                /*if(data.radiation.TOTALRADIATION == null){
                    totalradiation = '辐射:　  w/m2';
                }else {
                    totalradiation = '辐射: '+data.radiation.TOTALRADIATION.toFixed(2)+' w/m2';
                }*/
            }else{
                if(data.speed == null){
                    totalradiation = '风速:　  m/s';
                }else {
                    totalradiation = '风速: '+data.speed.toFixed(2)+' m/s';
                }

            }
            /* popup.setLatLng(e.latlng).setContent(
                 '<div class="weather-card madrid" style="color: whitesmoke;width: 130px;height: 80px;background-color: #0b3349">' +
                 '<table class="table table-bordered" style="margin-bottom: 0px;">' +
                 '<tr>' + '<th style="width: 90px;text-align: right">预警信号名称</th>' + '<td>1</td></tr>' +
                 '<tr>' + '<th style="width: 90px;text-align: right">发布单位</th>' + '<td>2</td></tr>' +
                 '<tr>' + '<th style="width: 90px;text-align: right">影响区域</th>' + '<td>3</td></tr> ' +
                 '<tr>' + '<th style="width: 90px;text-align: right">预警内容</th>' + '<td>4</td></tr>' +
                 '<tr>' + '<th style="width: 90px;text-align: right">预警发布时间</th>' + '<td>5</td></tr>' +
                 '<tr>' + '<th style="width: 90px;text-align: right">预警截止时间</th>' + '<td>6</td></tr>' +
                 '</table>' +
                 '</div>'
             ).openOn(map);*/
            var popup = L.popup({maxWidth:'200px',maxHeight:'120px'})
                .setLatLng(e.latlng)
                .setContent('<div id="stationInfo" style="color:#f5f5f5;width:170px;height:60px;background-color:#0b3349">' +
                    '<table style="margin-left:5px">' +
                    '<tbody>' +
                    '<tr>' +
                    '<td><a id="farmName" href="../main/frame?farmId='+farmID+'"  target="_self" style="font-size: 22px;">'+farmName+'</a>' +
                    '</td>' +
                    '</tr>' +
                    '<tr>' +
                    '<td id="totalradiation" style="font-size: 17px">' +totalradiation+
                    '</td>' +
                    '</tr>' +
                    '<tr>' +
                    '<td id="activepower" style="font-size: 17px">' +activepower+
                    '</td>' +
                    '</tr>' +
                    '</tbody>' +
                    '</table>' +
                    '</div>')
                .openOn(map);
            $('.leaflet-popup-content-wrapper').css({"background-color":"#0b3349","width":"200px","height":"120px"});


            /*layer.open({
                type: 1,
                shade: false,
                title: false, //不显示标题
                content: $('#stationInfo'), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
                //maxmin: true, //开启最大化最小化按钮
                // area: ['150px', '100px'],
                cancel: function(){
                    //layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', {time: 5000, icon:6});
                }
            });*/
        }
    })


    //首页数据加载调用 参数为farmID





}

//点击光伏/风电/全部 站点
function showStation(e){
    var type  = e.id;
    var farmname;

    selFarmid = null;

    if(type=='GF'){
        if (map.hasLayer(markergroup_FD[0])) {
            $.each(markergroup_FD, function (i, val) {
                map.removeLayer(val);
            })
        }
        if (!map.hasLayer(markergroup_GF[0])) {
            $.each(markergroup_GF, function (i, val) {
                val.addTo(map);
            })
        }
        $('#FD').attr('src','../img/header-icon4.png')
        $('#GF').attr('src','../img/header-icon2.png')
        farmname = '光伏';
    }else if(type=='FD'){
        farmname = '风电';
        if (map.hasLayer(markergroup_GF[0])) {
            $.each(markergroup_GF, function (i, val) {
                map.removeLayer(val);
            })
        }
        if (!map.hasLayer(markergroup_FD[0])) {
            $.each(markergroup_FD, function (i, val) {
                val.addTo(map);
            })
        }
        $('#GF').attr('src','../img/header-icon4.png')
        $('#FD').attr('src','../img/header-icon1.png')
    }else if(type=='ALL'){
        $('#GF').attr('src','../img/header-icon2.png')
        $('#FD').attr('src','../img/header-icon1.png')
        farmname = '全部';
        if (!map.hasLayer(markergroup_GF[0])) {
            $.each(markergroup_GF, function (i, val) {
                val.addTo(map);
            })
        }
        if(!map.hasLayer(markergroup_FD[0])){
            $.each(markergroup_FD, function (i, val) {
                val.addTo(map);
            })
        }
    }


    $('#dataSpace').html(farmname);
    ////首页数据加载调用  参数为type
    loadFarmData(type);


}

function openShuiParticulars(e) {
    var url = '../ShuiHuoParticularController/shuiParticular';
    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: 0.8,
        resize: false,
        maxmin: false, //开启最大化最小化按钮
        area: ['1200px', '580px'],
        content: url
    });
}

function openHuoParticulars(e) {
    var url = '../ShuiHuoParticularController/huoParticular';
    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: 0.8,
        resize: false,
        maxmin: false, //开启最大化最小化按钮
        area: ['1200px', '580px'],
        content: url
    });
}

function openFenbushiParticulars(e) {
    var url = '../ShuiHuoParticularController/fenbushiParticular';
    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: 0.8,
        resize: false,
        maxmin: false, //开启最大化最小化按钮
        area: ['1200px', '580px'],
        content: url
    });
}

function showNowMetCityforecast() {
    showCityForcastFlag = !showCityForcastFlag;
    addCityForcast(showCityForcastFlag);
}

function showNowMetAlarm() {
    showAlarmFlag = !showAlarmFlag;
    addMetAlarm(showAlarmFlag);
}

function showRadiation() {
    showSbtuFlag = !showSbtuFlag;
    addRadiation(showSbtuFlag);
}

function showWindCanvas()
{
    showWindCanvasFlag = !showWindCanvasFlag;
    addWindCanvas(showWindCanvasFlag);
}

//地图相关数据定时加载
function addWeather(){

    addCityForcast(showCityForcastFlag);
    addMetAlarm(showAlarmFlag);
    addRadiation(showSbtuFlag);
    addWindCanvas(showWindCanvasFlag);
}

var stationID;
function showWeatherInfo(a){
    $("#"+stationID).parent().parent().css("z-index","0");
    stationID = a.className;
    $(".weatherInfo").css("display", "none");
    $("#"+stationID).css("display", "block");
    $("#"+stationID).parent().parent().css("z-index","9999999999999")
}

function hideWeatherInfo() {
    $("#"+stationID).parent().parent().css("z-index","0")
    $(".weatherInfo").css("display", "none");
}

function openWeatherLayer(e){//

    var url=$(e).attr('data-url');
    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: false,
        maxmin: false, //开启最大化最小化按钮
        area: ['1000px', '700px'],
        content: url
    });
}

function openCenterCdq(e){//

    var url=$(e).attr('data-url');
    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: false,
        maxmin: false, //开启最大化最小化按钮
        area: ['1000px', '700px'],
        content: url
    });
}
function openNorthCdq(e){//

    var url=$(e).attr('data-url');
    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: false,
        maxmin: false, //开启最大化最小化按钮
        area: ['1000px', '700px'],
        content: url
    });
}

//加载天气预报
function addCityForcast(visi){
    if (map.hasLayer(markergroup_weahther[0])) {

        $.each(markergroup_weahther, function (i, val) {
            map.removeLayer(val);
        })

        markergroup_weahther = [];

        if (!visi)  //不显示天气预报
        {



            return;
        }
    }

    //显示天气预报
    var LeafIcon = L.Icon.extend({
        options: {
            iconSize: [35, 35],//width height
            iconAnchor: [10, 10], //左  上
        }
    });

    $.ajax({
        url: "../metCityForecast/getNowMetCityForecast",
        data: {},
        type: "post",
        success: function (data) {
            if(data.length==0){
                layer.msg('当前时段无数据',1000);
            }
            for(var i=0;i<data.length;i++){
                var h24WeatherCode =  data[i].h24WeatherCode;
                var h48WeatherCode =  data[i].h48WeatherCode;
                var h72WeatherCode =  data[i].h72WeatherCode;
                var h96WeatherCode =  data[i].h96WeatherCode;
                var h120WeatherCode =  data[i].h120WeatherCode;
                var h144WeatherCode =  data[i].h144WeatherCode;
                var h168WeatherCode =  data[i].h168WeatherCode;
                var h24Weather =  data[i].h24Weather;
                var h24HTemp =  data[i].h24HTemp;
                var h24LTemp =  data[i].h24LTemp;
                var stationNo =  data[i].StationNo;
                var CountyName =  data[i].CountyName;
                var Latitude =  data[i].Latitude;
                var Longitude =  data[i].Longitude;
                var iconUrl = "../img/weatherIcon/wp_"+h24WeatherCode+".png";
                var Icons = new LeafIcon({iconUrl: iconUrl});
                /**   var name = decodeURIComponent(params["stationname"]);
                 var stationid = decodeURIComponent(params["stationid"]);
                 var forecasttime = decodeURIComponent(params["forecasttime"]);
                 var province = decodeURIComponent(params["province"]);**/
                var htmlTable = '';
                var myIcon = L.divIcon({
                    className: 'my-div-icon',
                    html: '<div style="height: auto;width: 150px;position:absolute;outline: none;">'
                        +'<div style="float: left;margin-right: 5px"><img onclick="showWeatherInfo(this)" class="'+stationNo+'" style="position:absolute;width:30px;height:30px;outline: none;-moz-user-select:none;cursor:pointer;z-index:10000;" src="../img/weatherIcon/wp_'+h24WeatherCode+'.png" ></div>'
                        +'<div style="float:left; background-color: #071f3a; color:#fff; margin-left: 30px; display: none; width: 100px; outline: none;border-radius: 5px;" class="weatherInfo" id='+stationNo+'>'
                        +'<a onclick="hideWeatherInfo()" style="display: inline-block;position:absolute;top:4px;right:26px;width:15px;height:15px;-moz-user-select:none;cursor:pointer;z-index:10000; color: #fff;"><span class="glyphicon glyphicon-remove"></span></a>'
                        +'<table style="margin-left: 5px">'+
                        '<tr>'+
                        // '<td><a id="info_city" href="javaScript:;" onclick="openWeatherLayer(this)" data-url="../metCityForecast/testChart?stationNo='+stationNo+'&CountyName='+CountyName+'&h24WeatherCode='+h24WeatherCode+'&h48WeatherCode='+h48WeatherCode+'&h72WeatherCode='+h72WeatherCode+'&h96WeatherCode='+h96WeatherCode+'&h120WeatherCode='+h120WeatherCode+'&h144WeatherCode='+h144WeatherCode+'&h168WeatherCode='+h168WeatherCode+'" target="_self" style="font-size: 14px;">'+CountyName+'</a></td>'+
                        '<td><a id="info_city" href="javaScript:;" onclick="openWeatherLayer(this)" data-url="../metCityForecast/testChart?stationNo='+stationNo+'&CountyName='+CountyName+'" target="_self" style="font-size: 14px;">'+CountyName+'</a></td>'+
                        '</tr>'+
                        '<tr>'+
                        '<td id="info_weather">'+h24Weather+'</td>'+
                        '</tr>'+
                        '<tr>'+
                        '<td id="info_temp">'+h24LTemp+'℃ / '+h24HTemp+'℃</td>'+
                        '</tr>'+
                        '</table>'+
                        '</div>'+
                        '</div>'

                });

                var marker_weahther = L.marker([Latitude, Longitude], {icon: myIcon});
                markergroup_weahther.push(marker_weahther);
                marker_weahther.addTo(map);
                marker_weahther._data = data[i];
            }

        }
    })
}

//加载灾害预警信号
function addMetAlarm(visi){
    if (map.hasLayer(markergroup_yj[0])) {
        $.each(markergroup_yj, function (i, val) {
            map.removeLayer(val);
        })
        markergroup_yj = [];
    }


    if (!visi)  //移除要素，不显示
    {

        return;
    }

    //加载预警信号
    var LeafIcon = L.Icon.extend({
        options: {
            iconSize: [30,30],//width height
            iconAnchor: [10, 10], //左  上
        }
    });

    $.ajax({
        url: "../metAlarm/getNowMetAlarm",
        data: {},
        type: "post",
        success: function (data) {
            if(data.length==0){
                layer.msg('当前时段无灾害预警');
                WarningWord = "当前时段无灾害预警!";
            }
            if(data.length>0){
                WarningWord="当前发布了"+data.length+"个站的灾害预警消息，请注意防范!"
            }
            for(var i=0;i<data.length;i++){
                var ALARM_Signal =  data[i].ALARM_Signal;
                console.log(ALARM_Signal);
                var Latitude =  data[i].LAT;
                var Longitude =  data[i].LON;
                var iconUrl = '../img/yjImages/'+ALARM_Signal+'.png';
                var Icons = new LeafIcon({iconUrl: iconUrl,iconSize: [50, 50],
                });
                var marker_yj = L.marker([Latitude, Longitude], {icon: Icons});
                markergroup_yj.push(marker_yj);
                //   markergroup_yj._data =  data[i];
                marker_yj.addTo(map);
                marker_yj._data = data[i];
                marker_yj.on('click', clickYjMarker);
            }
        }
    })
}

//点击预警图标弹出信息
function clickYjMarker(e){
    var GUID =e.target._data.GUID;
    $.ajax({
        url: "../metAlarm/getAlarm",
        data: {guid: GUID},
        type: "get",
        success: function (data) {

            var itime = new Date();
            itime.setTime(data.IssueTime);

            var popup = L.popup({});
            popup.setLatLng(e.latlng).setContent(
                data.alarm_SIGNAL.replace('信号','') + " <br><hr>"
                + data.Content + "<br><hr>"
                + itime.Format("yyyy-MM-dd hh:mm")

            ).openOn(map);

        }
    })
}

//显示光辐射
function addRadiation(visi){

    if (!visi) {
        if (map.hasLayer(sebantu)) {
            map.removeLayer(sebantu);
            $("#irr").css("display", "none");//第1种方法
            $("#timeline-irr").css("display", "none");//第1种方法
            flag=false;
        }
    }
    else {

        //加载图例
        $("#irr").css("display", "block");//第1种方法
        loadTimeIrr();
        //生成色斑图
        var index = layer.load(1);
        if (map.hasLayer(sebantu)) {
            map.removeLayer(sebantu);
        }
        /*map.eachLayer((layer) => {
            if (layer instanceof L.Polyline || layer instanceof L.Marker || layer instanceof L.Circle)
        layer.remove();
    });*/

        //var url = "../irradianceManage/generate";
        $.getJSON('../irradianceManage/generate',{ftime:new Date()}, function (data) {
            console.log(data);
            sebantu = L.geoJSON(data, {
                style: function (feature) {
                    return {
                        color: feature.properties.color,
                        stroke: false,
                        fillOpacity: 0.5
                    };
                }
            })
            flag=true;
            sebantu.addTo(map);

            layer.close(index);
        })
    }
}
function loadTimeIrr() {
    $("#timeline-irr").css("display", "block");//第1种方法

    var nowYmd = moment().format("YYYY-MM-DD");

    var foreTimeline = $("#fore-timeline");
    foreTimeline.empty();
    var initHtml = '<div class="sliderbar"> <div class="growline" style="width: 0;"></div> <div class="staticline"></div> <div class="clickline"></div> <div class="datebox" style="left: 0;"><div>00:00</div><div class="datebox-trangle-bottom"></div>'+
        '</div> <div class="timetipbox"> <div></div><div class="timetip-trangle-bottom"></div></div></div><div class="showbar"></div>'
    foreTimeline.append(initHtml);  //支持重置


    var showbar = foreTimeline.find(".showbar");
    for (var i = 0; i < 10; i++) {
        showbar.append('<div class="showcell">' + moment(nowYmd).add(i, 'days').format('M月D日') + '</div>');
    }
    var cells = foreTimeline.find(".showcell");
    var datebox = foreTimeline.find(".datebox");
    var totalWidth = foreTimeline.width();
    var timetipbox = foreTimeline.find(".timetipbox");
    var initWidth = moment().hours() / 24 * totalWidth / cells.length ;
    foreTimeline.find(".growline").width(initWidth);
    datebox.css("left", initWidth + "px").children().eq(0).html(moment().format("HH") + ":00");
    foreTimeline
        .on("click", ".showcell", function () {
            var cellIndex = cells.index(this);
            var width = totalWidth * cellIndex / cells.length ;
            var time = moment(nowYmd).add(cellIndex, "days");
            foreTimeline.find(".growline").animate({
                width: width + "px"
            }, "fast");
            datebox.css("left", width + "px").children().eq(0).html(time.format("HH:mm"));
            currentData_time_cache = time.valueOf();

            updateGradeCacheIrr(time.toDate(), updMapGradeDataIrr);

        })
        .on("click", ".clickline", function (e) {
            var offsetTime = e.offsetX / totalWidth * cells.length;
            var days = Math.ceil(offsetTime);
            offsetTime = (offsetTime - days) * 24;
            var hours = Math.ceil(offsetTime);
            var width = (days + hours / 24) / cells.length * totalWidth / this.pane ;
            var time = moment(nowYmd).add(days, "days").add(hours, "hours");
            foreTimeline.find(".growline").animate({
                width: width + "px"
            }, "fast");
            datebox.css("left", width + "px").children().eq(0).html(time.format("HH:mm"));
            currentData_time_cache = time.valueOf();

            updateGradeCacheIrr(time.toDate(),updMapGradeDataIrr);

        })
        .on("mousemove", ".clickline", function (e) {
            var offsetTime = e.offsetX / totalWidth * cells.length;
            var days = Math.ceil(offsetTime);
            offsetTime = (offsetTime - days) * 24;
            var hours = Math.ceil(offsetTime);
            var time = moment(nowYmd).add(days, "days").add(hours, "hours");
            if (Math.abs(foreTimeline.find(".growline").width() - e.offsetX) < 54) {
                timetipbox.css("top", "-7em");
            }
            else {
                timetipbox.css("top", "-4em");
            }
            timetipbox.css("opacity", 1).css("left", (e.offsetX - 12) + "px").children().eq(0).html(time.format("HH:mm"));
        })
        .on("mouseleave", ".clickline", function () {
            timetipbox.animate({opacity: 0}, "fast");
        });
}
function updMapGradeDataIrr() {
    var index = layer.load(1);
    if (map.hasLayer(sebantu)) {
        map.removeLayer(sebantu);
    }

    sebantu = L.geoJSON(irrdata, {
        style: function (feature) {
            return {
                color: feature.properties.color,
                stroke: false,
                fillOpacity: 0.5
            };
        }
    })
    sebantu.addTo(map);

    layer.close(index);

}
var irrdata;
function updateGradeCacheIrr(time, callback) {

    if (map.hasLayer(sebantu)) {
        map.removeLayer(sebantu);
    }
    //var layerLoading1 = layer.load(1, {shade: [0.7, '#777']});
    var currentTime;
    if (time != null) {
        currentTime = time;
    } else {
        currentTime = new Date();
    }
    var index = layer.load(1);
    $.getJSON('../irradianceManage/generate',{ftime: currentTime}, function (data) {

        //layer.close(layerLoading1);

        irrdata = data;
        layer.close(index);
        callback();
    })
}

//风场流向图
function addWindCanvas(visi) {

    if (windCanvsLayer != null &&  map.hasLayer(windCanvsLayer)) {
        map.removeLayer(windCanvsLayer);
    }

    windCanvsLayer = null;

    if (!visi)  //移除要素，不显示
    {
        $("#direction").css("display", "none");//第1种方法
        $("#timeline-wind").css("display", "none");//第1种方法
        return;
    }

    $("#direction").css("display", "block");//第1种方法
    loadTimeLine();
    var ftime = new Date();  //预报时间暂时取当前时间，后面加上时间轴

    $.getJSON('../home/getEDA',{ftime: ftime}, function (data) {

        if(!data.success){
            layer.msg(data.dat);
            return;
        }

        windCanvsLayer = L.velocityLayer({
            displayValues: true,
            displayOptions: {
                velocityType: 'Global Wind',
                displayPosition: 'bottom',
                displayEmptyString: 'No wind data'
            },
            data: JSON.parse(data.dat),
            maxVelocity: 15
        });

        map.addLayer(windCanvsLayer);

        //加载图例



        $(".leaflet-bottom").css("left","50%");
        $(".leaflet-bottom").css("bottom","165px");
        $(".leaflet-control-velocity").css("position","relative");
        $(".leaflet-control-velocity").css("left","-50%");

    });
}
function loadTimeLine() {
    $("#timeline-wind").css("display", "block");//第1种方法
    var params = {};

    var baseTimeLine = $("#base-timeline");
    baseTimeLine.empty();
    baseTimeLine.html("");  //支持重置
    baseTimeLine.TimeSlider(params, clickback);


}
function clickback(time) {
    //currentData_time_cache = getTime(time);
    var requerTime = time.getTime();
    var currentTime = new Date().getTime();

    if (requerTime <= currentTime) {
        updateGradeCache(time,updMapGradeData);


    } else {
        // updateForecastGradeCache(time);
        updateGradeCache(time,updMapGradeData);


    }
};
function updMapGradeData() {
    if (windCanvsLayer != null &&  map.hasLayer(windCanvsLayer)) {
        map.removeLayer(windCanvsLayer);
    }

    windCanvsLayer = null;

    windCanvsLayer = L.velocityLayer({
        displayValues: true,
        displayOptions: {
            velocityType: 'Global Wind',
            displayPosition: 'bottom',
            displayEmptyString: 'No wind data'
        },
        data: JSON.parse(winddat),
        maxVelocity: 15
    });

    map.addLayer(windCanvsLayer);

    $(".leaflet-bottom").css("left","50%");
    $(".leaflet-bottom").css("bottom","165px");
    $(".leaflet-control-velocity").css("position","relative");
    $(".leaflet-control-velocity").css("left","-50%");


}
var winddat = null;
function updateGradeCache(time, callback) {

    //var layerLoading1 = layer.load(1, {shade: [0.7, '#777']});
    var currentTime;
    if (time != null) {
        currentTime = time;
    } else {
        currentTime = new Date();
    }

    $.getJSON('../home/getEDA',{ftime: currentTime}, function (data) {

        //layer.close(layerLoading1);
        if(!data.success){
            //layer.msg(data.dat);
            if (windCanvsLayer != null &&  map.hasLayer(windCanvsLayer)) {
                map.removeLayer(windCanvsLayer);
            }

            windCanvsLayer = null;
            return;
        }
        winddat = data.dat;
        callback();
    })
}

//发电占比
function drawEcharts1(wf, sf, fbs) {
    var myChartL = echarts.init(document.getElementById('indexChart1'));

    var optionL = {
        tooltip: {
            trigger: 'item',
            position: ['40%', -20],
            formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
            data: ['风电', '光伏', '分布式'],
            textStyle: {
                color: '#fff'
            },
            itemGap: 5,//图例间距
            bottom: '2%',
            left: "center"
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '5%',
            y: 0,
            containLabel: true
        },
        series: [
            {
                name:'发电占比',
                type:'pie',
                center: ['50%', '40%'],
                radius: ['50%', '65%'],
                avoidLabelOverlap: false,
                label: {
                    normal: {
                        show: false,
                        position: 'center'
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '18',
                        }
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                color: ['#33bbff', '#ffeb4e', '#FF6633'],
                data: [
                    {value: wf, name: '风电'},
                    {value: sf, name: '光伏'},
                    {value: fbs, name: '分布式'}
                ]
            }
        ]
    };
    myChartL.setOption(optionL);
}

//首页左侧数据，刷新周期从5分钟改成了15分钟，by 孙延维 20221003
setInterval('leftInfo()',300000*3);//定时刷新

//预报预警定时刷新；
// setInterval('addMetAlarm(true)',300000);//定时刷新
// setInterval('addCityForcast(true)',300000);//定时刷新

function leftInfo(){
    // var index = layer.load(1);
    $.getJSON('../home/leftInfo', '', function (_data) {
        //今日发电
        //预报发电量
        $("#forePower").text(((_data.forePower)).toFixed(2));

        //实际发电量
        // 因为以前是5分钟一个实况，现在实况是15分钟一个实况，所以把*5/60/10 改成了*15/60/10 ，by 孙延维 20220816
        $("#skPower").text(((_data.todayPower.power) * 15 / 60 / 10).toFixed(2));

        //$("#skPower").append(""+(_data.todayPower.power*0.25*1000/10000).toFixed(2)+"<small>万度</small>");


        //设备信息
        $("#capacitySum").text((_data.capacitySum).toFixed(2) + " MW"); //总装机容量
        $("#sfCapacity").text((_data.sfCapacity).toFixed(2) + " MW");//风电装机容量
        $("#wfCapacity").text((_data.wfCapacity).toFixed(2) + " MW");//光伏装机容量
        $("#sfNum").text(_data.sfNum + "个");//风电场个数
        $("#wfNum").text(_data.wfNum + "个");//光伏电站个数

        //发电占比

        //alert(_data.wfpower.power.toFixed(2));
        //alert(_data.sfpower.power.toFixed(2));

        if(_data.wfpower==null||_data.sfpower==null){
            drawEcharts1(0, 0, 0);
        }else {
            drawEcharts1(_data.wfpower.toFixed(2), _data.sfpower.toFixed(2), _data.fbsforecast.toFixed(2));
        }

        // layer.close(index);
    })
}

//未来三天电量预测
//setInterval('drawEcharts2()',300000);//定时刷新
function drawEcharts2(practiceData,forepower,installCapacity){
    var myChart = echarts.init(document.getElementById('indexChart2'));
    var colors = ['#6eb2ff', '#FF0000'];
    option = {
        // backgroundColor: '#071f3a',//背景色
        color: colors,
        tooltip: {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'line'        // 默认为直线，可选为：'line' | 'shadow'
            },
            /*formatter:function(params)//数据格式
            {
                var relVal = params[0].name+"<br/>";
                relVal += params[0].seriesName+ ' : ' + params[0].value+"<br/>";
                relVal +=params[1].seriesName+ ' : ' +params[1].value+"<br/>";
                return relVal;
            }*/


        },
        legend: {
            show:true,
            //orient:'horizontal',
            //borderWidth:2,
            data:[
                {
                    name:'实际网供',
                    textStyle:{
                        fontSize:12,
                        fontWeight:'bolder',
                        color:'#fff'
                    },
                    //icon:'image://../img/legend/1.png'//格式为'image://+icon文件地址'，其中image::后的//不能省略
                },
                {
                    name:'预测网供',
                    textStyle:{
                        fontSize:12,
                        fontWeight:'bolder',
                        color:'#fff'
                    },
                    //  icon:'image://../img/legend/4.png'//格式为'image://+icon文件地址'，其中image::后的//不能省略
                }
            ]
        },
        toolbox: {
            show: true,
            feature: {
                // mark: {show: true},
                // dataZoom: {show: true},
                //dataView: {show: true},
                // magicType: {show: true, type: ['line', 'bar', 'stack', 'tiled']},
                //restore: {show: true},
                // saveAsImage: {show: true}
            }
        },
        calculable: false,//取消拖拽
        dataZoom: {
            show: false,
            realtime: false,
            start: 0,
            end: 90,
            type:'inside'
        },
        xAxis: [
            {
                // interval:'auto',//X轴的刻度间隔
                splitLine:{show: false},//去除网格线
                type: 'time',
                boundaryGap:true,
                //data: date,
                axisLabel:{
                    formatter: '{value}',
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff"
                    }
                }
            }
        ],
        yAxis: [
            {
                splitLine:{show: false},//去除网格线
                name: '功率(MW)',
                max:installCapacity,
                min:0,
                nameTextStyle:{
                    color:'#fff'
                },
                type: 'value',
                axisLabel:{
                    formatter: '{value}'/*+'mw'*/,
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff"
                    }
                }
            }
        ],
        series: [
            {
                name: '实际网供',
                type: 'line',
                yAxisIndex: 0,
                symbol:'none',  //这句就是去掉点的
                data: practiceData
            }, {
                name: '预测网供',
                type: 'line',
                yAxisIndex: 0,
                data: forepower,
                symbol:'none',  //这句就是去掉点的
                itemStyle:{
                    normal:{
                        lineStyle:{
                            //type:'dotted'dashed  //'dotted'虚线 'solid'实线
                            //color: '#3300FF',
                            //type: 'dotted',
                            shadowBlur: 10,
                            shadowColor: 'rgba(0, 0, 0, 0.5)',
                            smooth:true,
                            //width:2//线宽
                        }
                    }
                }

            }
        ]
    };
    myChart.setOption(option);
}


//setInterval('drawEcharts3()',300000);//定时刷新
//短期功率预测对比
function drawEcharts3(skData,foreData,installCapacity){
    var myChart = echarts.init(document.getElementById('indexChart3'));
    var colors = ['#6eb2ff', '#FF0000'];
    option = {
        // backgroundColor: '#071f3a',//背景色
        color: colors,
        tooltip: {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'line'        // 默认为直线，可选为：'line' | 'shadow'
            },
        },
        legend: {
            show:true,
            //orient:'horizontal',
            //borderWidth:2,
            data:[
                {
                    name:'实际功率',
                    textStyle:{
                        fontSize:12,
                        fontWeight:'bolder',
                        color:'#fff'
                    },
                    //icon:'image://../img/legend/1.png'//格式为'image://+icon文件地址'，其中image::后的//不能省略
                },
                {
                    name:'预测功率',
                    textStyle:{
                        fontSize:12,
                        fontWeight:'bolder',
                        color:'#fff'
                    },
                    //  icon:'image://../img/legend/4.png'//格式为'image://+icon文件地址'，其中image::后的//不能省略
                }
            ]
        },
        toolbox: {
            show: true,
            feature: {
                // mark: {show: true},
                // dataZoom: {show: true},
                //dataView: {show: true},
                // magicType: {show: true, type: ['line', 'bar', 'stack', 'tiled']},
                //restore: {show: true},
                // saveAsImage: {show: true}
            }
        },
        calculable: false,//取消拖拽
        dataZoom: {
            show: false,
            realtime: false,
            start: 0,
            end: 100,
            type:'inside'
        },
        xAxis: [
            {
                interval:'auto',//X轴的刻度间隔
                splitLine:{show: false},//去除网格线
                type: 'time',
                boundaryGap:true,
                //data: date,
                axisLabel:{
                    formatter: '{value}',
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff"
                    }
                }
            }
        ],
        yAxis: [
            {
                splitLine:{show: false},//去除网格线
                name: '功率(MW)',
                max:installCapacity,
                min:0,
                nameTextStyle:{
                    color:'#fff'
                },
                type: 'value',
                axisLabel:{
                    formatter: '{value}'/*+'mw'*/,
                    rotate:-40,
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff",
                        fontSize:10
                    }
                }
            }
        ],
        series: [
            {
                name: '实际功率',
                type: 'line',
                yAxisIndex: 0,
                symbol:'none',  //这句就是去掉点的
                data: skData
            }, {
                name: '预测功率',
                type: 'line',
                yAxisIndex: 0,
                data: foreData,
                symbol:'none',  //这句就是去掉点的
                itemStyle:{
                    normal:{
                        lineStyle:{
                            //type:'dotted'dashed  //'dotted'虚线 'solid'实线
                            //color: '#3300FF',
                            //type: 'dotted',
                            shadowBlur: 10,
                            shadowColor: 'rgba(0, 0, 0, 0.5)',
                            smooth:true,
                            //width:2//线宽
                        }
                    }
                }

            }
        ]
    };
    myChart.setOption(option);
}

//负荷预测对比
function drawEcharts4(skData, originForeData, foreData, installCapacity) {
    var myChart = echarts.init(document.getElementById('indexChart4'));
    var colors = ['#6eb2ff', '#FF0000', '#98FB98'];
    option = {
        // backgroundColor: '#071f3a',//背景色
        color: colors,
        tooltip: {
            trigger: 'axis',
            axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                type: 'line'        // 默认为直线，可选为：'line' | 'shadow'
            },
        },
        legend: {
            show:true,
            //orient:'horizontal',
            //borderWidth:2,
            data: [
                {
                    name: '实际负荷',
                    textStyle: {
                        fontSize: 12,
                        fontWeight: 'bolder',
                        color: '#fff'
                    },
                },
                {
                    name: '预测负荷',
                    textStyle: {
                        fontSize: 12,
                        fontWeight: 'bolder',
                        color: '#fff'
                    },
                },
                {
                    name: '响应后预测负荷',
                    textStyle: {
                        fontSize: 12,
                        fontWeight: 'bolder',
                        color: '#fff'
                    },
                }
            ]
        },
        toolbox: {
            show: true,
            feature: {
            }
        },
        calculable: false,//取消拖拽
        dataZoom: {   //start和end表示X轴坐标范围，end为100表示完全显示，否则X轴的坐标无法显示完整
            show: false,
            realtime: false,
            start: 0,
            end: 100
        },
        xAxis: [
            {
                splitLine:{show: false},//去除网格线
                type: 'time',
                boundaryGap:true,
                axisLabel:{
                    formatter: '{value}',
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff"
                    }
                }
            }
        ],
        yAxis: [
            {
                splitLine:{show: false},//去除网格线
                name: '功率(MW)',
                max:installCapacity,
                min:0,
                nameTextStyle:{
                    color:'#fff'
                },
                type: 'value',
                axisLabel:{
                    formatter: '{value}'/*+'mw'*/,
                    rotate:-40,
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff",
                        fontSize:10
                    }
                }
            }
        ],
        series: [
            {
                name: '实际负荷',
                type: 'line',
                yAxisIndex: 0,
                symbol: 'none',  //这句就是去掉点的
                data: skData
            },
            {
                name: '预测负荷',
                type: 'line',
                yAxisIndex: 0,
                data: originForeData,
                symbol: 'none',  //这句就是去掉点的
                itemStyle: {
                    normal: {
                        lineStyle: {
                            shadowBlur: 10,
                            shadowColor: 'rgba(0, 0, 0, 0.5)',
                            smooth: true,
                            //width:2//线宽
                        }
                    }
                }

            },
            {
                name: '响应后预测负荷',
                type: 'line',
                yAxisIndex: 0,
                data: foreData,
                symbol: 'none',  //这句就是去掉点的
                itemStyle: {
                    normal: {
                        lineStyle: {
                            shadowBlur: 10,
                            shadowColor: 'rgba(0, 0, 0, 0.5)',
                            smooth: true,
                            //width:2//线宽
                        }
                    }
                }

            }
        ]
    };
    myChart.setOption(option);
}

//网供预测对比
function drawEcharts6(skData,foreData,installCapacity){
    var myChart = echarts.init(document.getElementById('indexChart6'));
    var colors = ['#6eb2ff', '#FF0000'];
    option = {
        // backgroundColor: '#071f3a',//背景色
        color: colors,
        tooltip: {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'line'        // 默认为直线，可选为：'line' | 'shadow'
            },
        },
        legend: {
            show:true,
            //orient:'horizontal',
            //borderWidth:2,
            data:[
                {
                    name:'实际网供',
                    textStyle:{
                        fontSize:12,
                        fontWeight:'bolder',
                        color:'#fff'
                    },
                    //icon:'image://../img/legend/1.png'//格式为'image://+icon文件地址'，其中image::后的//不能省略
                },
                {
                    name:'预测网供',
                    textStyle:{
                        fontSize:12,
                        fontWeight:'bolder',
                        color:'#fff'
                    },
                    //  icon:'image://../img/legend/4.png'//格式为'image://+icon文件地址'，其中image::后的//不能省略
                }
            ]
        },
        toolbox: {
            show: true,
            feature: {
            }
        },
        calculable: false,//取消拖拽
        dataZoom: {  //表示横左边的范围，end为100表示横坐标完全显示
            show: false,
            realtime: false,
            start: 0,
            end: 100,
            type:'inside'
        },
        xAxis: [
            {
                interval:'auto',//X轴的刻度间隔
                splitLine:{show: false},//去除网格线
                type: 'time',
                boundaryGap:true,
                //data: date,
                axisLabel:{
                    formatter: '{value}',
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff"
                    }
                }
            }
        ],
        yAxis: [
            {
                splitLine:{show: false},//去除网格线
                name: '功率(MW)',
                max:installCapacity,
                min:0,
                nameTextStyle:{
                    color:'#fff'
                },
                type: 'value',
                axisLabel:{
                    formatter: '{value}'/*+'mw'*/,
                    rotate:-40,
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff",
                        fontSize:10
                    }
                }
            }
        ],
        series: [
            {
                name: '实际网供',
                type: 'line',
                yAxisIndex: 0,
                symbol:'none',  //这句就是去掉点的
                data: skData
            }, {
                name: '预测网供',
                type: 'line',
                yAxisIndex: 0,
                data: foreData,
                symbol:'none',  //这句就是去掉点的
                itemStyle:{
                    normal:{
                        lineStyle:{
                            //type:'dotted'dashed  //'dotted'虚线 'solid'实线
                            //color: '#3300FF',
                            //type: 'dotted',
                            shadowBlur: 10,
                            shadowColor: 'rgba(0, 0, 0, 0.5)',
                            smooth:true,
                            //width:2//线宽
                        }
                    }
                }

            }
        ]
    };
    myChart.setOption(option);
}

//setInterval('drawEcharts5()',300000);//定时刷新
//超短期功率预测对比
function drawEcharts5(skData,foreData,intallCapacity){
    var myChart = echarts.init(document.getElementById('indexChart5'));
    var colors = ['#6eb2ff', '#FF0000'];
    option = {
        // backgroundColor: '#071f3a',//背景色
        color: colors,
        tooltip: {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'line'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        legend: {
            show:true,
            //orient:'horizontal',
            //borderWidth:2,
            data:[
                {
                    name:'实际功率',
                    textStyle:{
                        fontSize:12,
                        fontWeight:'bolder',
                        color:'#fff'
                    },
                    // icon:'image://../img/legend/1.png'//格式为'image://+icon文件地址'，其中image::后的//不能省略
                },
                {
                    name:'预测功率',
                    textStyle:{
                        fontSize:12,
                        fontWeight:'bolder',
                        color:'#fff'
                    },
                    //  icon:'image://../img/legend/4.png'//格式为'image://+icon文件地址'，其中image::后的//不能省略
                }
            ]
        },
        toolbox: {
            show: true,
            feature: {
                // mark: {show: true},
                // dataZoom: {show: true},
                //dataView: {show: true},
                // magicType: {show: true, type: ['line', 'bar', 'stack', 'tiled']},
                //restore: {show: true},
                // saveAsImage: {show: true}
            }
        },
        calculable: false,//取消拖拽
        dataZoom: {
            show: false,
            realtime: false,
            start: 0,
            end: 100,
            type:'inside'
        },
        xAxis: [
            {
                // interval:0,//X轴的刻度间隔
                splitLine:{show: false},//去除网格线
                type: 'time',
                boundaryGap:true,
                //data: date,
                axisLabel:{
                    formatter: '{value}',
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff"
                    }
                }
            }
        ],
        yAxis: [
            {
                splitLine:{show: false},//去除网格线
                name: '功率(MW)',
                max:intallCapacity,
                min:0,
                nameTextStyle:{
                    color:'#fff'
                },
                type: 'value',
                axisLabel:{
                    formatter: '{value}'/*+'mw'*/,
                    rotate:-40,
                    textStyle:{
                        fontWeight:"bolder",
                        color:"#fff",
                        fontSize:10
                    }
                }
            }
        ],
        series: [
            {
                name: '实际功率',
                type: 'line',
                yAxisIndex: 0,
                symbol:'none',  //这句就是去掉点的
                data: skData
            }, {
                name: '预测功率',
                type: 'line',
                yAxisIndex: 0,
                data: foreData,
                symbol:'none',  //这句就是去掉点的
                itemStyle:{
                    normal:{
                        lineStyle:{
                            //width:2,
                            //type:'dotted'dashed  //'dotted'虚线 'solid'实线
                            //color: '#3300FF',
                            //type: 'dotted',
                            shadowBlur: 10,
                            shadowColor: 'rgba(0, 0, 0, 0.5)',
                            smooth:true,
                            // width:1//线宽
                        }
                    }
                }

            }
        ]
    };
    myChart.setOption(option);
}

//加载单个电站的信息
function  loadOneStationData(farmid,farmtype) {
    //三日电量预测
    var date = new Array();//日期（今日，明天，后天）
    var power = new Array();//电量
    var InstallCapa =null;

    var dqskData = new Array();//短期实况数据
    var dqforeData = new Array();//短期预报数据

    var cdqskData = new Array();//超短期实况数据
    var cdqforeData = new Array();//超短期预报数据

    var dateTime = new Array();//时间
    var exact = new Array();//准确率

    selFarmid = farmid;

    var p={
        farmid:farmid,
        farmtype:farmtype
    };
    $.getJSON('../home/showOneStation',p, function (data) {

        InstallCapa =data.installcapa;//装机容量
        if(InstallCapa==null){
            layer.msg("请设置装机容量！", {icon: 1});
            return;
        }

        var newInstallCapa = parseFloat(InstallCapa);
        newInstallCapa+=10;


        //短期功率对比
        dq = data.dqlist;

        $.each(data.dqlist.dq, function (index, item) {
            var time = new Date(parseInt(item.time)).Format("yyyy-MM-dd hh:mm");
            dqforeData.push({name:time,value:[time,item.power.toFixed(2)]});
            //foreData.push({name:time,value:[time,item.foreData.toFixed(2)]});
        });

        var  times = 15;
        var min=null;
        $.each(data.dqlist.sk, function (index, item) {
            var time = new Date(parseInt(item.time)).Format("yyyy-MM-dd hh:mm");
            min = time.substring(14,16);
            if(min%times==0){
                dqskData.push({name: time, value: [time, item.power.toFixed(2)]});
            }

            //foreData.push({name:time,value:[time,item.foreData.toFixed(2)]});
        });

        drawEcharts3(dqskData, dqforeData, newInstallCapa);

        //超短期功率对比
        $.each(data.cdqlist.cdq, function (index, item) {
            var time = new Date(parseInt(item.time)).Format("yyyy/MM/dd hh:mm:ss");
            cdqforeData.push({name: time, value: [time, item.power.toFixed(2)]});
        });
        $.each(data.cdqlist.sk, function (index, item) {
            var time = new Date(parseInt(item.time)).Format("yyyy/MM/dd hh:mm:ss");
            min = time.substring(14, 16);
            if (min % times == 0) {
                cdqskData.push({name: time, value: [time, item.power.toFixed(2)]});
            }
        });
        drawEcharts5(cdqskData, cdqforeData, newInstallCapa);

        //七天电量预测时间
        $.each(data.listdate, function (index, item) {
            var time = new Date(parseInt(item)).Format("yyyy-MM-dd");
            date.push(time);
        });
        date[0] = '今天';
        date[1] = '明天';


        console.log(data.threedayMap.todayMap);
        if(data.threedayMap.todayMap!=null){
            power.push((data.threedayMap.todayMap).toFixed(2));
        }else {
            power.push(0);
        }
        if(data.threedayMap.tomorrowMap!=null){
            power.push((data.threedayMap.tomorrowMap).toFixed(2));
        }else {
            power.push(0);
        }
        if(data.threedayMap.afterMap!=null){
            power.push((data.threedayMap.afterMap).toFixed(2));
        }else {
            power.push(0);
        }
        if(data.threedayMap.fourMap!=null){
            power.push((data.threedayMap.fourMap).toFixed(2));
        }else {
            power.push(0);
        }
        if(data.threedayMap.fiveMap!=null){
            power.push((data.threedayMap.fiveMap).toFixed(2));
        }else {
            power.push(0);
        }
        if(data.threedayMap.sixMap!=null){
            power.push((data.threedayMap.sixMap).toFixed(2));
        }else {
            power.push(0);
        }
        if(data.threedayMap.sevenMap!=null){
            power.push((data.threedayMap.sevenMap).toFixed(2));
        }else {
            power.push(0);
        }


        //power.push((data.threedayMap.tomorrowMap).toFixed(2));
        //power.push((data.threedayMap.afterMap).toFixed(2));
        // drawEcharts2(date,power);

    })
}

//加载整场的信息，刷新周期从5分钟改成了15分钟，by 孙延维 20221003
setInterval('loadFarmData("ALL")',300000*3);//定时刷新
function loadFarmData(type){

    //网供预测
    var wgSkData = new Array();//实际网供
    var wgforeData = new Array();//预测网供

    //电场今日功率对比
    var dqskData = new Array();//实况数据
    var dqforeData = new Array();//短期数据

    var fuheSkData = new Array();//负荷实况数据
    var fuheforeData = new Array();//负荷预报数据
    var originFuheForeData = new Array();//负荷预报核减前的数据

    var cdqskData = new Array();//超短期实况数据
    var cdqforeData = new Array();//超短期预报数据

    //直方图
    var farmname = new Array();//电站名称
    var exact = new Array();//准确率
    $.ajax({
        url: "../home/showPortionStation",
        type: "get",
        contentType : "application/json",
        dataType : "json",
        data :{"type":type}/*JSON.stringify(data)*/,//转换成字符串。后台使用了RequestBody注解
        success : function(data) {

            //短期功率对比
            $.each(data.dqmap.dqlist, function (index, item) {
                var time = new Date(parseInt(item.time)).Format("yyyy/MM/dd hh:mm:ss");
                dqforeData.push({name:time,value:[time,item.power.toFixed(2)]});
            });
            var  times = 15;
            var min=null;
            $.each(data.dqmap.sklist, function (index, item) {
                var time = new Date(parseInt(item.observetime)).Format("yyyy/MM/dd hh:mm:ss");
                min = time.substring(14,16);
                if(min%times==0){
                    dqskData.push({name:time,value:[time,item.power.toFixed(2)]});
                }

                //foreData.push({name:time,value:[time,item.foreData.toFixed(2)]});
            });
            drawEcharts3(dqskData,dqforeData,Math.ceil(data.installMap.intallCapacity));



            //负荷功率对比
            $.each(data.fhmap.ycfhlist, function (index, item) {
                /**
                 * 由于负荷预测的时间和power格式不适合之前方式，所以进行了更改
                 * value:[time,item.forecastResult] forecastResult是根据数据库中返回字段决定的，如果返回字段
                 * 设计为power就是power;设计为forecastResult就是forecastResult
                 * update 凌 2021.9.15
                 **/
                var time = new Date(item.time).Format("yyyy/MM/dd hh:mm:ss");
                fuheforeData.push({name: time, value: [time, item.forecastResult]});
                // layer.msg("data.fhmap.ycfhlist的长度="+data.fhmap.ycfhlist.length);
            });
            $.each(data.fhmap.ycfhlist, function (index, item) {
                var time = new Date(item.time).Format("yyyy/MM/dd hh:mm:ss");
                originFuheForeData.push({name: time, value: [time, item.originForecastResult]});
            });
            var times = 15;
            var min = null;
            $.each(data.fhmap.sjfhlist, function (index, item) {
                var time = new Date(parseInt(item.time)).Format("yyyy/MM/dd hh:mm:ss");
                min = time.substring(14, 16);
                if (min % times == 0) {
                    fuheSkData.push({name: time, value: [time, item.skResult.toFixed(2)]});
                }
            });
            // drawEcharts4(fuheSkData,fuheforeData,Math.ceil(data.installFHMap.intallCapacity)+500);
            drawEcharts4(fuheSkData, originFuheForeData, fuheforeData, 3600);


            //网供功率对比
            $.each(data.wgmap.ycwglist, function (index, item) {
                var time = new Date(item.time).Format("yyyy/MM/dd hh:mm:ss");
                var wgforecastResult = item.forecastResult;
                if (wgforecastResult == null) {
                    wgforeData.push({name: time, value: [time, wgforecastResult]});
                } else {
                    wgforeData.push({name: time, value: [time, wgforecastResult.toFixed(2)]});
                }
            });
            $.each(data.wgmap.sjwglist, function (index, item) {
                var time = new Date(parseInt(item.time)).Format("yyyy/MM/dd hh:mm:ss");
                min = time.substring(14,16);
                if(min%times==0){
                    wgSkData.push({name:time,value:[time,item.skResult.toFixed(2)]});
                }
                //foreData.push({name:time,value:[time,item.foreData.toFixed(2)]});
            });
            drawEcharts6(wgSkData,wgforeData,3600);


            //超短期功率对比
            $.each(data.cdqmap.cdqlist, function (index, item) {
                var time = new Date(parseInt(item.time)).Format("yyyy/MM/dd hh:mm:ss");
                cdqforeData.push({name:time,value:[time,item.power.toFixed(2)]});
                //foreData.push({name:time,value:[time,item.foreData.toFixed(2)]});
            });


            $.each(data.cdqmap.sklist, function (index, item) {
                var time = new Date(parseInt(item.observetime)).Format("yyyy/MM/dd hh:mm:ss");
                min = time.substring(14,16);
                if(min%times==0){
                    cdqskData.push({name:time,value:[time,item.power.toFixed(2)]});
                }
                //foreData.push({name:time,value:[time,item.foreData.toFixed(2)]});
            });
            drawEcharts5(cdqskData,cdqforeData,Math.ceil(data.installMap.intallCapacity));



        }
    });
}


//单击数据监测
function openAllLight(e){//
    var url=$(e).attr('data-url');
    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: 0.8,
        resize:false,
        maxmin: false, //开启最大化最小化按钮
        area: ['1200px', '617px'],
        content: url
    });
}

//单击负荷预测右侧的详情，显示负荷预测对比功率的详细
function openLoadForecastParticulars(e){
    var url=$(e).attr('data-url');

    var type = $("#dataSpace").html();
    if(type == '全部'){
        type = 'ALL'
        url = url + '?type='+type;
    }else if(type == '风电'){
        type = 'FD'
        url = url + '?type='+type;
    }else if(type == '光伏'){
        type = 'GF'
        url = url + '?type='+type;
    }else {
        url = url + '?type='+type;
    }
    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: 0.8,
        resize:false,
        maxmin: false, //开启最大化最小化按钮
        area: ['1200px', '580px'],
        content: url
    });
}

//单击短期功率右侧的详情，显示短期对比功率的详细
function openShortParticulars(e){//
    var url=$(e).attr('data-url');

    var type = $("#dataSpace").html();
    if(type == '全部'){
        type = 'ALL'
        url = url + '?type='+type;
    }else if(type == '风电'){
        type = 'FD'
        url = url + '?type='+type;
    }else if(type == '光伏'){
        type = 'GF'
        url = url + '?type='+type;
    }else {
        url = url + '?type='+type;
    }

    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: 0.8,
        resize:false,
        maxmin: false, //开启最大化最小化按钮
        area: ['1000px', '580px'],
        content: url
    });
}

//单击超短期功率右侧的详情，显示短期对比功率的详细
function openSpuerShortParticulars(e){
    var url=$(e).attr('data-url');

    var type = $("#dataSpace").html();
    if(type == '全部'){
        type = 'ALL'
        url = url + '?type='+type;
    }else if(type == '风电'){
        type = 'FD'
        url = url + '?type='+type;
    }else if(type == '光伏'){
        type = 'GF'
        url = url + '?type='+type;
    }else {
        url = url + '?type='+type;
    }
    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: 0.8,
        resize:false,
        maxmin: false, //开启最大化最小化按钮
        area: ['900px', '580px'],
        content: url
    });
}

//单击七天电量预测右侧的详情，显示七天电量预测的详细
function opensevenPower(e){//
    var url=$(e).attr('data-url');

    var type = $("#dataSpace").html();
    if(type == '全部'){
        type = 'ALL'
        url = url + '?type='+type;
    }else if(type == '风电'){
        type = 'FD'
        url = url + '?type='+type;
    }else if(type == '光伏'){
        type = 'GF'
        url = url + '?type='+type;
    }else {
        url = url + '?type='+type;
    }

    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: 0.8,
        resize:false,
        maxmin: false, //开启最大化最小化按钮
        area: ['1200px', '580px'],
        content: url
    });
}

//鼠标悬浮在负荷预测，详情图标上 ，切换图片
function fhmouseOver(){
    document.getElementById("fhycicon").src="../img/move.png";
}
//鼠标离开负荷预测，详情图标上 ，切换图片
function fhmouseOut(){
    document.getElementById('fhycicon').src ="../img/normal.png"
}

//鼠标悬浮在网供预测，详情图标上 ，切换图片
function wgmouseOver(){
    document.getElementById("wgycicon").src="../img/move.png";
}
//鼠标离开网供预测，详情图标上 ，切换图片
function wgmouseOut(){
    document.getElementById('wgycicon').src ="../img/normal.png"
}

//鼠标悬浮在短期，详情图标上 ，切换图片
function dqmouseOver(){
    document.getElementById("dqicon").src="../img/move.png";
}
//鼠标离开短期，详情图标上 ，切换图片
function dqmouseOut()
{
    document.getElementById('dqicon').src ="../img/normal.png"
}
//鼠标悬浮在超短期，详情图标上 ，切换图片

function cdqmouseOver(){
    document.getElementById("cdqicon").src="../img/move.png";
}
//鼠标离开超短期，超短期详情图标上 ，切换图片
function cdqmouseOut()
{
    document.getElementById('cdqicon').src ="../img/normal.png"
}

//鼠标悬浮在七天电量预测，详情图标上 ，切换图片

function sevenPowermouseOver(){
    document.getElementById("sevenPower").src="../img/move.png";
}
//鼠标离开七天电量预测，七天电量预测详情图标上 ，切换图片
function sevenPowermouseOut()
{
    document.getElementById('sevenPower').src ="../img/normal.png"
}

function goToDetail() {

    if (selFarmid != null)
        window.location.href  = "../main/frame?farmId="+ selFarmid;
    else
        window.location.href  = "../main/frame";
}